<template>
  <div class="container">
    <a-row :gutter="16">
      <a-col :span="20">
        <a-space :size="16" style="width: 100%" direction="vertical">
          <div class="index-card">
            <div>
              <div>
                <p>待付款</p>
                <h3>{{ shopOrderStatistics.waitPayNum }}</h3>
              </div>
              <img src="/image/index_icon1.png" alt="" />
            </div>
            <div>
              <div>
                <p>待发货</p>
                <h3>{{ shopOrderStatistics.waitSentNum }}</h3>
              </div>
              <img src="/image/index_icon2.png" alt="" />
            </div>
            <div>
              <div>
                <p>待鉴定</p>
                <h3>{{ shopOrderStatistics.waitIdentifiedNum }}</h3>
              </div>
              <img src="/image/index_icon3.png" alt="" />
            </div>
            <div>
              <div>
                <p>待收货</p>
                <h3>{{ shopOrderStatistics.waitReceivedNum }}</h3>
              </div>
              <img src="/image/index_icon4.png" alt="" />
            </div>
            <div>
              <div>
                <p>待售后</p>
                <h3>{{ shopOrderStatistics.waitSaleNum }}</h3>
              </div>
              <img src="/image/index_icon5.png" alt="" />
            </div>
          </div>
          <a-card title="营业数据">
            <div v-if="countData" class="account">
              <div>
                <h4>在售商品</h4>
                <h3>{{ countData.saleGoodsCount }}</h3>
              </div>
              <div>
                <h4>今日浏览量</h4>
                <h3>{{ countData.visitor }}</h3>
                <p>昨日数据：{{ countData.yesterdayVisitor }}</p>
              </div>
              <div>
                <h4>今日商品分享</h4>
                <h3>{{ countData.sharedNumber }}</h3>
                <p>昨日数据：{{ countData.yesterdaySharedNumber }}</p>
              </div>
              <div>
                <h4>今日交易数</h4>
                <h3>{{ countData.paymentCount }}</h3>
                <p>昨日数据：{{ countData.yesterdayPaymentCount }}</p>
              </div>
              <div>
                <h4>今日营业总额</h4>
                <h3>{{ countData.totalPayment || 0 }}</h3>
                <p>昨日数据：{{ countData.yesterdayTotalPayment || 0 }}</p>
              </div>
            </div>
            <a-typography-title :level="5">近12月营业走势</a-typography-title>
            <echartsBar
              class="chart"
              height="height:160px"
              ref="echarts"
            ></echartsBar>
          </a-card>
          <a-card>
            <a-tabs v-model:activeKey="isActiveVal">
              <a-tab-pane key="1" tab="全部">
                <div class="index-tab-content">
                  <div class="tag">
                    <a-tag class="taga" color="#BAE7FF">订单</a-tag>
                    <span>2021-8-8 12:32</span>
                    <a>4512JI23312JQ4J</a>
                    <span>订单商品鉴定失败，准备退回中。</span>
                  </div>
                  <div class="tag">
                    <a-tag class="taga" color="#BAE7FF">订单</a-tag>
                    <span>2021-8-8 12:32</span>
                    <a>4512JI23312JQ4J</a>
                    <span>订单商品鉴定失败，准备退回中。</span>
                  </div>
                </div>
              </a-tab-pane>
              <a-tab-pane key="2" tab="系统通知" force-render
                ><div class="index-tab-content">
                  <div class="tag">
                    <a-tag class="taga" color="#BAE7FF">订单</a-tag>
                    <span>2021-8-8 12:32</span>
                    <a>4512JI23312JQ4J</a>
                    <span>订单商品鉴定失败，准备退回中。</span>
                  </div>
                  <div class="tag">
                    <a-tag class="taga" color="#BAE7FF">订单</a-tag>
                    <span>2021-8-8 12:32</span>
                    <a>4512JI23312JQ4J</a>
                    <span>订单商品鉴定失败，准备退回中。</span>
                  </div>
                </div></a-tab-pane
              >
              <a-tab-pane key="3" tab="订单通知"
                ><div class="index-tab-content">
                  <div class="tag">
                    <a-tag class="taga" color="#BAE7FF">订单</a-tag>
                    <span>2021-8-8 12:32</span>
                    <a>4512JI23312JQ4J</a>
                    <span>订单商品鉴定失败，准备退回中。</span>
                  </div>
                  <div class="tag">
                    <a-tag class="taga" color="#BAE7FF">订单</a-tag>
                    <span>2021-8-8 12:32</span>
                    <a>4512JI23312JQ4J</a>
                    <span>订单商品鉴定失败，准备退回中。</span>
                  </div>
                </div></a-tab-pane
              >
              <a-tab-pane key="4" tab="物流通知"
                ><div class="index-tab-content">
                  <div class="tag">
                    <a-tag class="taga" color="#BAE7FF">订单</a-tag>
                    <span>2021-8-8 12:32</span>
                    <a>4512JI23312JQ4J</a>
                    <span>订单商品鉴定失败，准备退回中。</span>
                  </div>
                  <div class="tag">
                    <a-tag class="taga" color="#BAE7FF">订单</a-tag>
                    <span>2021-8-8 12:32</span>
                    <a>4512JI23312JQ4J</a>
                    <span>订单商品鉴定失败，准备退回中。</span>
                  </div>
                </div></a-tab-pane
              >
            </a-tabs>
          </a-card>
          <a-card title="爆款商机">
            <div class="card-tips">
              智能小客服提醒您！我们将会智能分析现在市场最火的爆款以及最稀缺的资源推送给您哦～
            </div>
            <div class="card-list">
              <div
                v-for="item in goodsHotList"
                :key="item.id"
                class="card-list-content"
              >
                <div class="flex">
                  <a-image style="width: 125px;height: 125px;" :src="item.coverPic"></a-image>
                  <div>
                    <div>{{ item.name }}</div>
                    <div>{{ item.collectNum }}人想要</div>
                    <div>¥2323.45～45353.23</div>
                  </div>
                </div>
                <div class="card-btn">
                  <img src="/image/card_icon.png" alt="" />
                  <span>去上架</span>
                </div>
              </div>
            </div>
          </a-card>
        </a-space>
      </a-col>
      <a-col :span="4">
        <a-space  :size="16" style="width: 100%" direction="vertical">
          <div class="my-shop">
            <div class="my-shop-info">
              <img :src="shopInfo.coverPic" alt="" />
              <div>
                <h3>{{ shopInfo.name }}</h3>
                <p>注册时间：{{ shopInfo.createdTime }}</p>
              </div>
            </div>
            <div class="my-shop-list">
              <div>
                <img src="/image/b_icon.png" alt="" />
                <span>{{ shopInfo.companyName }}</span>
              </div>
              <div>
                <img src="/image/s_icon.png" alt="" />
                <span>{{ shopInfo.code }}</span>
              </div>
              <div>
                <img src="/image/b_icon.png" alt="" />
                <div>
                  <span v-for="item in goodsTypeList" :key="item.id">{{
                    item.name
                  }}</span>
                </div>
              </div>
            </div>
            <div class="my-shop-tab">
              <div>
                <h3>65</h3>
                <p>关注数</p>
              </div>
              <div>
                <h3>65</h3>
                <p>分享数</p>
              </div>
              <div>
                <h3>65</h3>
                <p>已售数</p>
              </div>
            </div>
            <div class="my-shop-msg">
              <BellOutlined />
              <p>客服消息</p>
            </div>
          </div>
          <div class="sell">
            <div>
              <img src="/image/sell_icon.png" alt="" />
              <p>出售商品</p>
            </div>
            <div>
              <img src="/image/sell_icon2.png" alt="" />
              <p>卖给平台</p>
            </div>
          </div>
          <a-card>
            <template #title>
              <div class="card-title">
                <img src="/image/like_icon.png" alt="" />
                <span>心愿排行榜</span>
              </div>
              <div class="hot-card">
                <div v-for="(item, index) in collectRankingList" :key="item.id">
                  <img class="hot-card-img" :src="item.coverPic" alt="" />
                  <span>{{ item.brandName }}</span>
                  <img
                    v-if="index <= 2"
                    class="hot-card-icon"
                    src="/image/fire_icon.png"
                    alt=""
                  />
                </div>
              </div>
            </template>
          </a-card>
        </a-space>
      </a-col>
    </a-row>
  </div>
</template>
<script setup>
import { BellOutlined } from "@ant-design/icons-vue";
import { ref, onMounted } from "vue";
import echartsBar from "../../components/echartsBar.vue";
import {
  getShopInfo,
  getShopOrderStatistics,
  countShopData,
  countOrderData,
} from "@/api/index";
import { goodsType } from "@/api/order";
import { goodsHot, collectRanking } from "@/api/goods";
const isActiveVal = ref("1");
const goodsTypeList = ref([]);
const shopInfo = ref({});
const getGoodsType = async () => {
  const result = await goodsType();
  if (result.code == 200) {
    getShopInfo().then((res) => {
      if (result.code == 200) {
        shopInfo.value = res.data;
        goodsTypeList.value = result.data.filter((val) =>
          res.data.mainTypes.some((e) => e == val.id)
        );
      }
    });
  }
};
const shopOrderStatistics = ref({});
const getShopOrderStatisticsList = async () => {
  const result = await getShopOrderStatistics();
  if (result.code == 200) {
    shopOrderStatistics.value = result.data;
  }
};
const countData = ref({});
const countShopDataList = async () => {
  const result = await countShopData();
  if (result.code == 200) {
    countData.value = result.data;
  }
};
const echarts = ref(null);
const countOrderDataFn = async () => {
  const result = await countOrderData();
  if (result.code == 200) {
    echarts.value.initEcharts(result.data);
  }
};
const collectRankingList = ref([]);
const getCollectRankingList = async () => {
  const result = await collectRanking({ page: 1, pageSize: 10 });
  if (result.code == 200) {
    collectRankingList.value = result.data.list;
  }
};
const goodsHotList = ref([]);
const getGoodsHotList = async () => {
  const result = await goodsHot();
  if (result.code == 200) {
    goodsHotList.value = result.data;
  }
};
onMounted(() => {
  getGoodsType();
  getShopOrderStatisticsList();
  countShopDataList();
  countOrderDataFn();
  getGoodsHotList();
  getCollectRankingList();
});
</script>
<style lang="less" scoped>
.index-card {
  display: flex;
  align-items: center;
  gap: 18px;
  > div {
    padding: 0 16px;
    flex: 1;
    height: 78px;
    background: #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    div {
      p {
        margin: 0;
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #262e47;
      }
      h3 {
        margin: 0;
        font-size: 18px;
        font-family: PingFang SC-Semibold, PingFang SC;
        font-weight: 600;
        color: #262e47;
      }
    }
    img {
      width: 42px;
      height: 42px;
    }
  }
}
.account {
  border-radius: 8px;
  display: flex;
  align-items: center;
  margin-bottom: 30px;
  padding: 24px 0;
  div {
    border-left: 1px solid #e8ecf0;
    flex: 1;
    text-align: center;
    h3 {
      font-size: 16px;
      font-family: PingFang SC-Semibold, PingFang SC;
      font-weight: 600;
      color: #262e47;
    }
    h4 {
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #262e47;
      line-height: 14px;
    }
  }
  div:first-child {
    border-left: 0;
  }
}
.index-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .index-tab-left {
    display: flex;
    align-items: center;
    div {
      font-size: 14px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #262e47;
      line-height: 16px;
      margin-right: 50px;
      padding-bottom: 2px;
      cursor: pointer;
    }
    .active {
      font-weight: 600;
      color: #262e47;

      border-bottom: 2px solid #262e47;
    }
  }
  .index-tab-right {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-family: PingFang SC-Regular, PingFang SC;
    font-weight: 400;
    color: #9fa3b0;
    line-height: 14px;
    img {
      width: 16px;
      height: 16px;
    }
  }
}
.index-tab-content {
  padding-top: 10px;
  .tag {
    display: flex;
    align-items: center;
    margin-top: 16px;
    > span {
      margin-left: 32px;
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #262e47;
      line-height: 14px;
    }
    > a {
      font-size: 12px;
      font-family: PingFang SC-Semibold, PingFang SC;
      font-weight: 600;
      color: #1990ff;
      line-height: 14px;
      margin-left: 32px;
    }
    .taga {
      margin: 0;
    }
  }
}
.card-tips {
  font-size: 12px;
  font-family: PingFang SC-Medium, PingFang SC;
  font-weight: 500;
  color: #262e47;
  line-height: 14px;
}
.card-list {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  .card-list-content {
    flex: 1;
    background: #f3f5f7;
    border-radius: 8px;
    padding: 16px;
    box-sizing: border-box;
    .flex {
      display: flex;
      align-items: center;
      justify-content: center;
      .image {
        width: 60px;
      }
      > div {
        div:first-child {
          font-size: 12px;
          font-family: PingFang SC-Medium, PingFang SC;
          font-weight: 500;
          color: #262e47;
          line-height: 14px;
        }
        div:nth-child(2) {
          font-size: 12px;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: #9599a5;
          line-height: 14px;
          margin: 4px 0;
        }
        div:last-child {
          font-size: 12px;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: #ff5151;
          line-height: 14px;
        }
      }
    }
    .card-btn {
      height: 29px;
      background: #262e47;
      border-radius: 4px;
      width: 100%;
      text-align: center;
      margin-top: 12px;
      img {
        width: 20px;
        height: 20px;
      }
      span {
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
        line-height: 14px;
        margin-left: 4px;
      }
    }
  }
}
.my-shop {
  padding: 16px;
  background-color: #ffffff;
  border-radius: 8px;
  .my-shop-info {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e8ecf0;
    padding-bottom: 12px;
    img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
    div {
      margin-left: 8px;
      h3 {
        font-size: 14px;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 500;
        color: #2b3453;
        line-height: 16px;
        margin: 0;
      }
      p {
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #9599a5;
        line-height: 14px;
        margin: 0;
      }
    }
  }
  .my-shop-list {
    margin-top: 12px;
    border-bottom: 1px solid #e8ecf0;
    padding-bottom: 12px;
    > div {
      display: flex;
      img {
        width: 20px;
        height: 20px;
        margin-right: 8px;
      }
      span {
        height: 17px;
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #2b3453;
        line-height: 14px;
        margin-right: 12px;
      }
    }
  }
  .my-shop-tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid #e8ecf0;
    div {
      text-align: center;
      h3 {
        font-size: 16px;
        font-family: PingFang SC-Semibold, PingFang SC;
        font-weight: 600;
        color: #262e47;
        line-height: 19px;
        margin: 0;
      }
      p {
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #262e47;
        line-height: 14px;
        margin: 0;
        margin-top: 8px;
      }
    }
  }
  .my-shop-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    p {
      font-size: 14px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #1990ff;
      line-height: 16px;
      margin-left: 4px;
      margin-bottom: 0;
    }
  }
}
.sell {
  display: flex;
  align-items: center;
  padding: 16px;
  background-color: #fff;
  border-radius: 8px;
  div {
    border-left: 1px solid #e8ecf0;
    flex: 1;
    text-align: center;
    cursor: pointer;
    img {
      width: 36px;
      height: 36px;
    }
    p {
      font-size: 12px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #000000;
      line-height: 14px;
      margin-top: 4px;
    }
  }
  div:first-child {
    border: none;
  }
}
.card-title {
  display: flex;
  align-items: center;
  padding: 16px 0 12px;
  border-bottom: 1px solid #e8ecf0;
  img {
    width: 20px;
    height: 20px;
  }
  span {
    margin-left: 4px;
    font-size: 14px;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #2b3453;
    line-height: 16px;
  }
}
.hot-card {
  padding-bottom: 16px;
  div {
    display: flex;
    align-items: center;
    margin-top: 12px;
    .hot-card-img {
      width: 20px;
      height: 20px;
      border-radius: 50%;
    }
    span {
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #2b3453;
      line-height: 14px;
      margin-left: 4px;
      cursor: pointer;
      width: 80%;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .hot-card-icon {
      width: 16px;
      height: 16px;
      margin-left: 12px;
    }
  }
}
.chart {
  height: 160px;
}
</style>
